package com.hp.demo.controller;

import com.alibaba.fastjson.JSON;
import com.hp.demo.bean.DataContext;
import com.hp.demo.service.ManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("manager")
public class ManagerController {
    @Autowired
    ManagerService managerService;
    @RequestMapping("/login")
    @ResponseBody
    public String login(@RequestParam Map map){
        DataContext data=new DataContext();
        List<Map> login = managerService.login(map);
        if (login.size()>0){
            data.setMsg("登录成功");
            data.setData(login);
            data.setCode(200);
            return JSON.toJSONString(data);
        }else {
            data.setMsg("登录失败");
            data.setCode(500);
            return JSON.toJSONString(data);
        }
    }
}
